home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / Editorial / Programming with Delphi 2005 / Delphi 2005 1 / TEST1 / TEST.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  2005-02-22  |  849 b   |  50 lines

  1. unit test;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, XPMan;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     CalcBtn: TButton;
  12.     GrandTotal: TEdit;
  13.     Vat: TEdit;
  14.     SubTotal: TEdit;
  15.     Label1: TLabel;
  16.     Label2: TLabel;
  17.     Label3: TLabel;
  18.     procedure CalcBtnClick(Sender: TObject);
  19.   private
  20.     { Private declarations }
  21.   public
  22.     { Public declarations }
  23.   end;
  24.  
  25. var
  26.   Form1: TForm1;
  27.  
  28. implementation
  29.  
  30. {$R *.DFM}
  31.  
  32.  
  33.  
  34. procedure TForm1.CalcBtnClick(Sender: TObject);
  35. var
  36.    st, vt, gt  : real;
  37.    errcode : integer;
  38. begin
  39.    Val(SubTotal.Text, st, errcode);
  40.    if errcode = 0 then
  41.    begin
  42.       vt := (st * 0.175);
  43.       gt := vt + st;
  44.       Vat.Text := FloatToStr(vt);
  45.       GrandTotal.Text := FloatToStr(gt);
  46.     end;
  47. end;
  48.  
  49. end.
  50.